Skip to content

Initial compile support for llama4 #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Initial compile support for llama4 #1365

wants to merge 1 commit into from

Conversation

xmfan
Copy link
Member

@xmfan xmfan commented Jul 3, 2025

Status

We don't have a good way in compile to specify fullgraph=True except for FSDP hooks at the moment. We can either leave it fullgraph=False or just wrap the experts model code in set_fullgraph(False)/set_fullgraph(True).

Repro

tested on debug model NGPU=2 CONFIG_FILE="./torchtitan/experiments/llama4/train_configs/debug_model.toml" ./run_train.sh --parallelism.data_parallel_shard_degree=2 --parallelism.expert_parallel_degree=2 --training.compile
logs: https://gist.github.com/xmfan/41b822d9f09eb07fee62d684a061cec1

memory: 2.20GiB -> 1.42GiB
speedup: no big change, need to check with actual model

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 3, 2025
Base automatically changed from ep to main July 8, 2025 16:47
@xmfan xmfan marked this pull request as ready for review July 16, 2025 17:51
@xmfan xmfan requested a review from tianyu-l July 16, 2025 17:51
@xmfan xmfan changed the title [WIP] Compile for dp2ep Initial compile support for llama4 Jul 16, 2025
@tianyu-l
Copy link
Contributor

pls try rebase #1403
which has non-persistent buffer for load-balancing fields

This is the original issue I mentioned
https://github.com/pytorch/torchtitan/blob/main/torchtitan/experiments/llama4/model/model.py#L382
where the freqs_cis should also be non-persistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants